
import { ElNotification, ElMessageBox, ElMessage } from 'element-plus'
export function p_error(str, fun, fun2) { // 第三个参数是关闭回调
  return new Promise((resolve, reject) => {
    ElMessageBox({
      title: '警告',
      message: str,
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      showCancelButton: true,
      type: 'error',
      confirmButtonClass: "el-button--danger",
      beforeClose: (action, instance, done) => {
        if (action === 'confirm') {
          fun(instance, done)
        } else {
          done()
        }
      },
    }).then((res)=>{
      resolve(res)
    }).catch((res) => {
      // reject(res)  // 如果返回需要捕获catch，故不调用
    }).finally(()=>{
      if(typeof fun2 != "undefined"){
        fun2()
      }
    })
  })
}